package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmGuoMinWuShuJu;
import com.ruoyi.web.admin.service.ITdmGuoMinWuShuJuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 过敏物数据库管理Controller
 * 
 * @author ly
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/admin/TdmGuoMinWuShuJu")
public class TdmGuoMinWuShuJuController extends BaseController
{
    @Autowired
    private ITdmGuoMinWuShuJuService tdmGuoMinWuShuJuService;

    /**
     * 查询过敏物数据库管理列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmGuoMinWuShuJu:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmGuoMinWuShuJu tdmGuoMinWuShuJu)
    {
        startPage();
        List<TdmGuoMinWuShuJu> list = tdmGuoMinWuShuJuService.selectTdmGuoMinWuShuJuList(tdmGuoMinWuShuJu);
        return getDataTable(list);
    }

    /**
     * 导出过敏物数据库管理列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmGuoMinWuShuJu:export')")
    @Log(title = "过敏物数据库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmGuoMinWuShuJu tdmGuoMinWuShuJu)
    {
        List<TdmGuoMinWuShuJu> list = tdmGuoMinWuShuJuService.selectTdmGuoMinWuShuJuList(tdmGuoMinWuShuJu);
        ExcelUtil<TdmGuoMinWuShuJu> util = new ExcelUtil<TdmGuoMinWuShuJu>(TdmGuoMinWuShuJu.class);
        util.exportExcel(response, list, "过敏物数据库管理数据");
    }

    /**
     * 获取过敏物数据库管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmGuoMinWuShuJu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmGuoMinWuShuJuService.selectTdmGuoMinWuShuJuById(id));
    }

    /**
     * 新增过敏物数据库管理
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmGuoMinWuShuJu:add')")
    @Log(title = "过敏物数据库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmGuoMinWuShuJu tdmGuoMinWuShuJu)
    {
        return toAjax(tdmGuoMinWuShuJuService.insertTdmGuoMinWuShuJu(tdmGuoMinWuShuJu));
    }

    /**
     * 修改过敏物数据库管理
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmGuoMinWuShuJu:edit')")
    @Log(title = "过敏物数据库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmGuoMinWuShuJu tdmGuoMinWuShuJu)
    {
        return toAjax(tdmGuoMinWuShuJuService.updateTdmGuoMinWuShuJu(tdmGuoMinWuShuJu));
    }

    /**
     * 删除过敏物数据库管理
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmGuoMinWuShuJu:remove')")
    @Log(title = "过敏物数据库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmGuoMinWuShuJuService.deleteTdmGuoMinWuShuJuByIds(ids));
    }
}
